from forest.command import Command
from forest.tool import Tool

import snack


screen = None

def finish():
    global screen
    screen.finish()

def help(screen, text):
    #raise ValueError, "foo"
    #window = screen.popWindow()
    #snack.ButtonChoiceWindow(screen, "Help", text, help = "Help on help")
    pass

def start():
    global screen
    screen = snack.SnackScreen()
    screen.helpCallback(help)


DEBUG = False

def default_handle_command_start(command):
    # command.__register__
    #window = screen.popWindow()
    
    #g = snack.GridForm(screen, "Tree", 1, 2)
    #g.add("   ", 0, 0, (0, 0, 0, 1))
    #g.runOnce()
    #snack.ButtonChoiceWindow(screen, "Help", command.__register__, buttons=[])
    pass

def default_handle_command_finish(command):
    # command.__register__
    pass
    
def default_handle_command_progress(command, percent=None, level=None, message=''):
    # pass
    pass
    

Command.SIGNAL_COMMAND_START.connect(default_handle_command_start)
Command.SIGNAL_COMMAND_PROGRESS.connect(default_handle_command_progress)
Command.SIGNAL_COMMAND_FINISH.connect(default_handle_command_finish)


def default_handle_tool_start(tool, level=None, message=''):
    # tool.__register__
    pass
    

def default_handle_tool_finish(tool, level=None, message=''):
    # tool.__register__
    pass

last_progress_name = None
progress = None


import progressbar
    
def default_handle_tool_progress(tool, progressdata=None, level=None, message=''):
    # tool.__register__
    pass
           

Tool.SIGNAL_TOOL_START.connect(default_handle_tool_start)
Tool.SIGNAL_TOOL_PROGRESS.connect(default_handle_tool_progress)
Tool.SIGNAL_TOOL_FINISH.connect(default_handle_tool_finish)
